package com.rogo.rogobox.views.components.controls
{
	import flash.events.Event;
	
	import mx.core.UIComponent;
	
	public class Loading extends UIComponent
	{
		public function Loading()
		{
			super();
			
			addEventListener(Event.ENTER_FRAME, enterFrameHandler);
		}
		
		private var curWidth:Number = 0;
		private var color:uint = 0x000000;
		
		override public function set visible(value:Boolean):void
		{
			super.visible = value;
			
			if (visible)
				curWidth = 0;
		}
		
		private function enterFrameHandler(e:Event):void
		{
			graphics.clear();
			graphics.beginFill(color, .8);
			graphics.drawRect(0, 0, curWidth, height);
			graphics.endFill();
			
			curWidth += 5;
			if (curWidth > width)
				curWidth = 0;
		}
		
	}
}